﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Web.Security;
using cognysClient.CognyService;

namespace cognysClient
{
    public partial class PRiC : System.Web.UI.Page
    {

        //private Service1Client client = new Service1Client();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        [WebMethod]
        public static void getAnswerArray(string[] answers)
        {
            using(var client = new Service1Client())
            {
                var userId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                var date = DateTime.Now.ToString();
                var questions = client.getPricQuestions();
                var index = 0;

                foreach(var item in questions)
                {
                    var results = new ResultPRiC();
                    results.Question = item.ID;
                    results.Answer = answers[index];
                    results.regDate = date;
                    results.Person = userId;
                    client.AddPricResult(results);
                    index++;
                }
            }
        }
    }
}